//
//  CanalyticsController.m
//  032519-友盟统计SDK
//
//  Created by 强进冬 on 2019/3/26.
//  Copyright © 2019 强进冬. All rights reserved.
//

#import "CanalyticsController.h"
#import "UMTool.h"

@interface CanalyticsController ()

@end

@implementation CanalyticsController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"统计";
}

#pragma mark - life cycle
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [MobClick beginLogPageView:NSStringFromClass(self.class)];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [MobClick endLogPageView:NSStringFromClass(self.class)];
}

#pragma mark - view event
/// 计数统计
- (IBAction)countEvent:(UIButton *)sender {
    NSDictionary *dict = @{@"type" : @"book", @"quantity" : @"3"};
    [MobClick event:@"count" attributes:dict];
}

/// 计算统计
- (IBAction)calculateEvent:(UIButton *)sender {
//    [MobClick event:@"calculate" attributes:@{@"book" : @"Swift Fundamentals"} counter:110];
    [MobClick beginEvent:@"calculate"];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [MobClick endEvent:@"calculate"];
    });
}

/// 页面统计
- (IBAction)pageStatistics:(UIButton *)sender {
    [MobClick logPageView:NSStringFromClass(self.class) seconds:100];
}

/// 账号统计
- (IBAction)accountStatistics:(UIButton *)sender {
    [MobClick profileSignInWithPUID:@"userID" provider:@"WB"];
//    [MobClick profileSignOff];
}

@end
